home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / cwscr.exe / MYSCR.H < prev    next >
Text File  |  1991-05-22  |  4KB  |  146 lines

  1. /*
  2.     Text Screen module class specification.
  3.  
  4.     This is the header file that should be used when text based output
  5.     to the screen is desired.
  6.  
  7.     Library : mycpp.lib
  8. */
  9.  
  10. #ifndef __MYSCR_H__
  11. #define __MYSCR_H__
  12.  
  13. static char MyScrh_Id[] = "myscr.h      1.10 05/22/91";
  14. /*
  15.     Version notes :
  16.         1.00 - Original creation / release. ( 2-14-91 CW )
  17.         1.10 - Added scroll function. Also changed all char * modifiers to
  18.                 const char *. ( 5-22-91 CW )
  19. */
  20.  
  21. #include <string.h>
  22.  
  23.  
  24. /* ================================================================== */
  25.  
  26. #ifndef TRUE
  27.     #define TRUE    1
  28.     #define FALSE   0
  29. #endif
  30.  
  31.  
  32. typedef enum { Scroll_Up, Scroll_Down } ScrollDir;
  33.  
  34. typedef struct {
  35.     unsigned char   ch;
  36.     unsigned char   attrib;
  37. } scr_type;
  38.  
  39. typedef struct {
  40.     int         x, y, w, h;
  41.     scr_type    *scr_ptr;
  42. } save_type;
  43.  
  44.  
  45. /* ------------------------------------------------------------------ */
  46. class myScreen {
  47.     scr_type    far *screen;
  48.     scr_type    far *tscr;
  49.     int         cursor_flag;    // true if cursor is visible.
  50.  
  51.     void init();
  52.  
  53. public:
  54.     myScreen(){ init(); };
  55.     ~myScreen(){ if( !cursor_flag ) cursor_show(); };
  56.  
  57.     void print( int x, int y, int attr, const char *str );
  58.     void print( int x, int y, const char *str ){
  59.         print( x, y, -1, str );
  60.     };
  61.     void print( int x, int y, int attr, const char chr );
  62.     void print( int x, int y, const char chr ){
  63.         print( x, y, -1, chr );
  64.     };
  65.     void clear( int x, int y, int w, int h, int attr = -1 );
  66.     void clear( int x, int y, int attr = -1 ){
  67.         clear( x, y, 1, 1, attr );
  68.     };
  69.     void clear( int attr = -1 ){
  70.         clear( 0, 0, 80, 24, attr );
  71.     };
  72.     void change( int x, int y, int w, int h, int attr );
  73.     void change( int x, int y, int attr ){
  74.         change( x, y, 1, 1, attr );
  75.     };
  76.     void change( int attr ){
  77.         change( 0, 0, 80, 24, attr );
  78.     };
  79.  
  80.     void scroll( ScrollDir dir, int x, int y, int w, int h, const char *str );
  81.     void scroll( ScrollDir dir, int x, int y, int w, int h ){
  82.         scroll( dir, x, y, w, h, "" );
  83.     };
  84.     void scroll( ScrollDir dir, const char *str ){
  85.         scroll( dir, 0, 0, 80, 24, str );
  86.     };
  87.     void scroll( ScrollDir dir ){
  88.         scroll( dir, 0, 0, 80, 24, "" );
  89.     };
  90.  
  91.     const save_type *save( int x, int y, int w, int h );
  92.     void restore( const save_type *data );
  93.  
  94.     void cursor_move( int x, int y );
  95.     void cursor_show();
  96.     void cursor_hide();
  97.     int  cursor_is_on(){ return( cursor_flag ); };
  98. };
  99.  
  100. /* :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:- */
  101. /*
  102.     The rest of this header file contains useful hash defines that can
  103.     be used to specify the values for the attribute ( attr ) parameters
  104.     in the above functions.
  105. */
  106.  
  107. #define SCR_F_Black     (0)
  108. #define SCR_F_Blue      (1)
  109. #define SCR_F_Green     (2)
  110. #define SCR_F_Cyan      (3)
  111. #define SCR_F_Red       (4)
  112. #define SCR_F_Purple    (5)
  113. #define SCR_F_Yellow    (6)
  114. #define SCR_F_White     (7)
  115.  
  116. #define SCR_B_Black     (SCR_F_Black  << 4)
  117. #define SCR_B_Blue      (SCR_F_Blue   << 4)
  118. #define SCR_B_Green     (SCR_F_Green  << 4)
  119. #define SCR_B_Cyan      (SCR_F_Cyan   << 4)
  120. #define SCR_B_Red       (SCR_F_Red    << 4)
  121. #define SCR_B_Purple    (SCR_F_Purple << 4)
  122. #define SCR_B_Yellow    (SCR_F_Yellow << 4)
  123. #define SCR_B_White     (SCR_F_White  << 4)
  124.  
  125. #define SCR_Fi_Black    (SCR_F_Black  | 8)
  126. #define SCR_Fi_Blue     (SCR_F_Blue   | 8)
  127. #define SCR_Fi_Green    (SCR_F_Green  | 8)
  128. #define SCR_Fi_Cyan     (SCR_F_Cyan   | 8)
  129. #define SCR_Fi_Red      (SCR_F_Red    | 8)
  130. #define SCR_Fi_Purple   (SCR_F_Purple | 8)
  131. #define SCR_Fi_Yellow   (SCR_F_Yellow | 8)
  132. #define SCR_Fi_White    (SCR_F_White  | 8)
  133.  
  134. #define SCR_Bb_Black    (SCR_B_Black  | 8)
  135. #define SCR_Bb_Blue     (SCR_B_Blue   | 8)
  136. #define SCR_Bb_Green    (SCR_B_Green  | 8)
  137. #define SCR_Bb_Cyan     (SCR_B_Cyan   | 8)
  138. #define SCR_Bb_Red      (SCR_B_Red    | 8)
  139. #define SCR_Bb_Purple   (SCR_B_Purple | 8)
  140. #define SCR_Bb_Yellow   (SCR_B_Yellow | 8)
  141. #define SCR_Bb_White    (SCR_B_White  | 8)
  142.  
  143. /* :-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:- */
  144.  
  145. #endif
  146.